<%-- 
    Document   : profile
    Created on : Jan 16, 2013, 1:26:21 PM
    Author     : SONY
--%>

<%@page import="model.Member"%>
<%@page import="model.User"%>
<%@page import="model.MemberService"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>

<%-- Report any errors (if any) --%>
<html:errors />
<% 
    User user = (User) session.getAttribute("user_member");
    MemberService member_service = new MemberService();
    Member member = member_service.getMemberDetails_byMID(user.getMemberID());
    String email = user.getEmail();
    String firstName = member.getFirstName();
    String lastName = member.getLastName();
    String gender = member.getGender();
    String address = member.getAddress();
    String phone = member.getPhone();
%>
<%-- Generate main body --%>
<html:form action="/member/profile.do" method="POST" acceptCharset="UTF-8">
    <table width=600 border=0>
        <tr>
            <td colspan=2 style="font-weight: bold;">Thông Tin Tài Khoản</td>
        </tr>
        <tr>
            <td width=200><span class="required">*&nbsp;</span>Email</td>
            <td width=400>
                <%-- Repopulate the Email field --%>
                <html:text property="email" value="<%=email%>" readonly="true" size="30" />
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <html:checkbox property="changePass"  /> Thay Đổi Mật Khẩu
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Mật Khẩu Hiện Tại</td>
            <td>
                <%-- Repopulate the Password field --%>
                <html:password property="passwordOld" size="30" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Mật Khẩu Mới</td>
            <td>
                <%-- Repopulate the Password field --%>
                <html:password property="passwordNew" size="30" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Nhập Lại Mật Khẩu Mới</td>
            <td>
                <%-- Repopulate the Password field --%>
                <html:password property="confirmpassNew" size="30" />
            </td>
        </tr>
    </table>
    <p>&nbsp;</p>
    <table width=600 border=0>
        <tr>
            <td colspan=2 style="font-weight: bold;">Thông Tin Giao Hàng</td>
        </tr>
        <tr>
            <td width=200><span class="required">*&nbsp;</span>Họ và Chữ Lót</td>
            <td width=400>
                <%-- Repopulate the LastName field --%>
                <html:text property="lastName" value="<%=lastName%>" size="30" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Tên</td>
            <td>
                <%-- Repopulate the FirstName field --%>
                <html:text property="firstName" value="<%=firstName%>" size="30" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Giới Tính<br /></td>
            <td>
                <%-- Repopulate the Gender drop-down menu --%>
                <html:select property='gender'>
                    <% if(gender.equals("F")) { %>
                        <html:option value="F">Nữ</html:option>
                        <html:option value="M">Nam</html:option>
                    <% } else { %>                       
                        <html:option value="M">Nam</html:option>
                        <html:option value="F">Nữ</html:option>
                    <% } %>
                </html:select>
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Điện Thoại Liên Hệ</td>
            <td>
                <%-- Repopulate the Phone field --%>
                <html:text property="phone" value="<%=phone%>" size="30" />
            </td>
        </tr>
        <tr>
            <td><span class="required">*&nbsp;</span>Địa Chỉ</td>
            <td>
                <%-- Repopulate the Street field --%>
                <html:text property="address" value="<%=address%>" size="60" />
            </td>
        </tr>
        <tr>
            <td colspan=2 align=center>
                <%-- The submit button --%>
                <html:submit value="Cập Nhật" styleClass="button"/>
            </td>
        </tr>
    </table>
</html:form>
<% 
if(((HttpServletRequest) request).getAttribute("success") != null) {
    String success = ((HttpServletRequest) request).getAttribute("success").toString();
    if(success.length() > 0) { 
        out.println("<script type=\"text/javascript\">");
        out.println("alert(\"" + success + "\")");
        out.println("</script>");
    }
} %>
